home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / mkmf / mkmf.man < prev    next >
Text File  |  1991-04-11  |  2KB  |  71 lines

  1. #!/sprite/cmds/csh -f
  2. #
  3. # A script to generate (or regenerate) the Makefile for a directory
  4. # consisting solely of header files.
  5. #
  6. # We assume we were invoked from mkmf.  Parameters passed in from mkmf
  7. # through environment variables:
  8. #
  9. #    MKMFDIR        directory containing prototype makefiles
  10. #    MAKEFILE    name of makefile to create
  11. #    SUBTYPE        additional information, telling whether this
  12. #            is an X directory, Sprite directory, etc.
  13. #
  14.  
  15. #
  16. # Argument processing.  (Generalized form, even though just one flag so far.)
  17. #
  18. while ($#argv >= 1)
  19.     if ("$1" == '-x') then
  20.     set echo
  21.     endif
  22.     shift
  23. end
  24.  
  25. set name=`expr $cwd : '.*/man/\(.*\)$'`
  26. set subtype=$SUBTYPE
  27. set makefile=$MAKEFILE
  28. set distdir=($DISTDIR)
  29.  
  30. if (-e $makefile.proto) then
  31.     set proto=$makefile.proto
  32. else
  33.     set proto="${MKMFDIR}/Makefile.man"
  34. endif
  35.  
  36. echo "Generating a Makefile for $name manual entries using $proto"
  37.  
  38. set nonomatch
  39. set manPages =( *.man )
  40. #
  41. # Check to see if there were any man pages.  The first check (size == 1)
  42. # is only necessary because the second check will cause an error if
  43. # hdrs contains more than 1024 bytes.
  44. #
  45. if ($#manPages == 1) then
  46.     if ("$manPages" == "*.man") set manPages=()
  47. endif
  48. unset nonomatch
  49.  
  50. #
  51. # Use sed to substitute various interesting things into the prototype
  52. # makefile. The code below is a bit tricky because some of the variables
  53. # being substituted in can be very long:  if the substitution is passed
  54. # to sed with "-e", the entire variable must fit in a single shell argument,
  55. # with a limit of 1024 characters.  By generating a separate script file
  56. # for the very long variables, the variables get passed through (to the
  57. # script file) as many arguments, which gets around the length problem.
  58. #
  59.  
  60. rm -f mkmf.tmp.sed
  61. echo s,"@(MANPAGES)",$manPages,g > mkmf.tmp.sed
  62. cat $proto | sed -f mkmf.tmp.sed \
  63.     -e "s,@(DATE),`date`,g" \
  64.     -e "s,@(MAKEFILE),$makefile,g" \
  65.     -e "s,@(NAME),$name,g" \
  66.     -e "s,@(TEMPLATE),$proto,g" \
  67.     -e "s,@(TYPE),$subtype,g" \
  68.     -e "s,@(DISTDIR),$distdir,g" \
  69.     > $makefile
  70. rm -f mkmf.tmp.sed
  71.